<template>
  <div class="student-dashboard">
    <!-- 主要内容区域 -->
    <div class="dashboard-container">
      <!-- 左侧主内容区 -->
      <div class="main-content">
        <!-- 标题区域 -->
        <div class="title-section">
          <div class="welcome-info">
            <div class="weather-icon">☀️</div>
            <div class="welcome-text">
              <span class="greeting">{{ $t('assets.dashboard.welcomeBack') }}，{{ userName }}</span>
            </div>
          </div>
        </div>

        <!-- 功能卡片区 -->
        <div class="function-cards">
          <div class="card-item purple-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/task.png" alt="学习任务" />
                </div>
                <h3>{{ $t('assets.dashboard.learningTask') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.learningTaskDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="createTask">
                <span class="btn-text">{{ $t('assets.dashboard.createTask') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToStudentTasks">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="任务管理" />
                </div>
                <span>{{ $t('assets.dashboard.taskManagement') }}</span>
              </button>
            </div>
          </div>

          <div class="card-item green-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/TeachingTasks.png" alt="作业提交" />
                </div>
                <h3>{{ $t('assets.dashboard.homeworkSubmission') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.homeworkSubmissionDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="submitHomework">
                <span class="btn-text">{{ $t('assets.dashboard.submitHomework') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToSubmissionHistory">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="提交记录" />
                </div>
                <span>{{ $t('assets.dashboard.submissionHistory') }}</span>
              </button>
            </div>
          </div>

          <div class="card-item blue-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/home01.png" alt="同学档案" />
                </div>
                <h3>{{ $t('assets.dashboard.classmateProfile') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.classmateProfileDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="goToClassmateList">
                <span class="btn-text">{{ $t('assets.dashboard.classmateProfile') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToClassmateList">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="查看同学" />
                </div>
                <span>{{ $t('assets.dashboard.viewClassmates') }}</span>
              </button>
            </div>
          </div>
        </div>   
     <!-- 分类列表区 -->
        <div class="category-section">
          <!-- 分类标签 -->
          <div class="category-tabs">
            <button v-for="category in categories" :key="category.key"
              :class="['category-tab-btn', { active: activeCategory === category.key }]"
              @click="activeCategory = category.key">
              {{ category.label }}
              <span class="count">{{ category.count }}</span>
            </button>
          </div>

          <!-- 分割线 -->
          <div class="divider-line"></div>

          <!-- 状态标签 -->
          <div class="status-tabs">
            <button v-for="status in statusList" :key="status.key"
              :class="['status-tab-btn', { active: activeStatus === status.key }]" @click="activeStatus = status.key">
              {{ status.label }}
            </button>
          </div>

          <!-- 作业列表 -->
          <div class="homework-list">
            <div v-for="homework in filteredHomework" :key="homework.id" class="homework-item"
              @click="viewHomework(homework)">
              <!-- <div class="subject-icon-wrapper" :class="homework.subject"> -->
                <img :src="getSubjectIconPath(homework.subject)" :alt="homework.subject" class="subject-icon" />
              <!-- </div> -->
              <div class="homework-content">
                <h4 class="homework-title">{{ homework.title }}</h4>
                <p class="homework-desc">{{ homework.description }}</p>
              </div>
              <div class="homework-meta">
                <div class="homework-time">
                  <div class="time-label">{{ $t('assets.dashboard.createdTime') }}</div>
                  <div class="time-value">{{ formatDate(homework.createdAt) }}</div>
                </div>
                <div class="homework-time">
                  <div class="time-label">{{ $t('assets.dashboard.completedTime') }}</div>
                  <div class="time-value">{{ formatDate(homework.dueDate) }}</div>
                </div>
              </div>
              <div class="homework-arrow">
                <img src="@/assets/right.png" alt="查看详情" class="arrow-icon" />
              </div>
            </div>

            <!-- 空状态 -->
            <EmptyState
              v-if="filteredHomework.length === 0"
              :text="$t('assets.dashboard.noTasksYet')"
              :button-text="$t('assets.dashboard.createTask')"
              @action="createTask"
            />
          </div>
        </div>
      </div>

      <!-- 右侧快捷入口区 -->
      <div class="sidebar-content">
        <!-- 快捷入口区 -->
        <div class="quick-actions-section">
          <div class="section-header">
            <h3>{{ $t('assets.dashboard.quickAccess') }}</h3>
          </div>
          <div class="quick-actions">
            <div class="quick-action-item" @click="goToHomeworkReview">
              <div class="action-icon">
                <img src="@/assets/Correction.png" alt="作业回顾" />
              </div>
              <span>{{ $t('assets.dashboard.homeworkReview') }}</span>
            </div>
            <div class="quick-action-item" @click="refreshData">
              <div class="action-icon">
                <img src="@/assets/errorCollection.png" alt="错题集" />
              </div>
              <span>{{ $t('assets.dashboard.errorCollection') }}</span>
            </div>
            <div class="quick-action-item" @click="createTask">
              <div class="action-icon">
                <img src="@/assets/TeachingTasks.png" alt="创建任务" />
              </div>
              <span>{{ $t('assets.dashboard.createTask') }}</span>
            </div>
            <div class="quick-action-item" @click="goToPersonalCenter">
              <div class="action-icon">
                <img src="@/assets/document.png" alt="个人中心" />
              </div>
              <span>{{ $t('assets.dashboard.personalCenter') }}</span>
            </div>
          </div>
        </div>

        <!-- 公告信息轮播区域 -->
        <el-carousel height="200px" :interval="4000" :loop="true" indicator-position="outside" class="custom-carousel">
          <el-carousel-item v-for="(item, index) in carouselItems" :key="index">
            <div class="carousel-item-content" :style="{ backgroundImage: item.image ? `url(${item.image})` : 'none' }">
              <div class="carousel-overlay"></div>
              <div class="carousel-text">
                <h4>{{ item.title }}</h4>
                <p>{{ item.description }}</p>
              </div>
            </div>
          </el-carousel-item>
        </el-carousel>

        <!-- 公告区域 -->
        <div class="announcement-section">
          <div class="section-header">
            <h3>{{ $t('assets.dashboard.announcement') }}</h3>
          </div>
          <div class="announcement-list">
            <div v-for="announcement in announcements" :key="announcement.id" class="announcement-item"
              @click="viewAnnouncement(announcement)">
              <div class="announcement-tag" :class="announcement.type">
                {{ announcement.tag }}
              </div>
              <div class="announcement-content">
                <div class="announcement-title">{{ announcement.title }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 摄像头弹窗 -->
    <el-dialog v-model="showCameraModal" title="作业提交" width="80%" :before-close="() => showCameraModal = false">
      <CameraCapture
        @close="showCameraModal = false"
        @photo-captured="handleHomeworkSubmission"
      />
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { t as $t } from '@/plugins/simpleI18n'
import CameraCapture from '@/components/shared/Camera/CameraCapture.vue'
import EmptyState from '@/components/shared/Common/EmptyState.vue'
import { photosStorage, type PhotoData } from '@/utils/photosDB'
import { ElMessage } from 'element-plus'

const router = useRouter()
const authStore = useAuthStore()

// 响应式数据
const activeCategory = ref('all')
const activeStatus = ref('all')
const showCameraModal = ref(false)

// 计算属性
const userName = computed(() => {
  return authStore.currentUser?.name || '同学'
})

// 分类数据
const categories = ref([
  { key: 'all', label: $t('assets.dashboard.categoryAll'), count: 12 },
  { key: 'math', label: $t('assets.dashboard.categoryMath'), count: 12 },
  { key: 'chinese', label: $t('assets.dashboard.categoryChinese'), count: 14 },
  { key: 'english', label: $t('assets.dashboard.categoryEnglish'), count: 12 },
  { key: 'other', label: $t('assets.dashboard.categoryOther'), count: 12 }
])

// 状态数据
const statusList = ref([
  { key: 'all', label: $t('assets.dashboard.statusAll'), count: 12 },
  { key: 'pending', label: $t('assets.dashboard.statusPending'), count: 3 },
  { key: 'working', label: $t('assets.dashboard.statusWorking'), count: 2 },
  { key: 'submitted', label: $t('assets.dashboard.statusSubmitted'), count: 1 },
  { key: 'reviewing', label: $t('assets.dashboard.statusReviewing'), count: 1 },
  { key: 'completed', label: $t('assets.dashboard.statusCompleted'), count: 5 }
])

// 作业列表数据
const homeworkList = ref([
  {
    id: 1,
    title: '这里是数学学习任务',
    description: '这里是一段数学学科描述',
    subject: 'math',
    status: 'pending',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 2,
    title: '这里是语文学习任务',
    description: '这里是一段语文学科描述',
    subject: 'chinese',
    status: 'working',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 3,
    title: '这里是英语学习任务',
    description: '这里是一段英语学科描述',
    subject: 'english',
    status: 'completed',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 4,
    title: '这里是其他学习任务',
    description: '这里是一段其他学科描述',
    subject: 'other',
    status: 'submitted',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 5,
    title: '这里是数学学习任务',
    description: '这里是一段数学学科描述',
    subject: 'other',
    status: 'reviewing',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 6,
    title: '这里是语文学习任务',
    description: '这里是一段语文学科描述',
    subject: 'chinese',
    status: 'pending',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  }
])

// 轮播图数据
const carouselItems = ref([
  {
    title: '学习系统升级',
    description: '全新学习功能，提升学习效率',
    image: '/src/assets/swpier/swpier01.jpg'
  },
  {
    title: '学习任务管理',
    description: '便捷的任务创建与管理工具',
    image: '/src/assets/swpier/swiper02.jpg'
  },
  {
    title: '同学档案系统',
    description: '完善的同学信息查看平台',
    image: '/src/assets/swpier/swiper03.jpg'
  },
  {
    title: '错题库功能',
    description: '智能错题收集与分析',
    image: '/src/assets/swpier/swiper04.jpg'
  },
  {
    title: '学习数据统计',
    description: '全面的学习数据可视化',
    image: '/src/assets/swpier/swiper05.jpg'
  }
])

// 公告数据
const announcements = ref([
  { id: 1, title: '内容最新优惠活动', type: 'activity', tag: $t('assets.dashboard.announcementActivity') },
  { id: 2, title: '新增内容尚未通过审核，详...', type: 'info', tag: $t('assets.dashboard.announcementInfo') },
  { id: 3, title: '当前产品试用期即将截止，...', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 4, title: '1月新系统升级计划通知', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 5, title: '新增内容已经通过审核，详...', type: 'info', tag: $t('assets.dashboard.announcementInfo') },
  { id: 6, title: '1月新系统升级计划通知', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 7, title: '1月新系统升级计划通知', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 8, title: '1月新系统升级计划通知', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 9, title: '1月新系统升级计划通知', type: 'notice', tag: $t('assets.dashboard.announcementNotice') },
  { id: 10, title: '1月新系统升级计划通知', type: 'notice', tag: '通知' }
])

// 计算过滤后的作业列表
const filteredHomework = computed(() => {
  let filtered = homeworkList.value

  if (activeCategory.value !== 'all') {
    filtered = filtered.filter(item => item.subject === activeCategory.value)
  }

  if (activeStatus.value !== 'all') {
    filtered = filtered.filter(item => item.status === activeStatus.value)
  }

  return filtered
})

// 方法
const formatDate = (date: Date) => {
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

const getSubjectIconPath = (subject: string) => {
  const iconPaths: Record<string, string> = {
    math: '/src/assets/subject/mathico.png',
    chinese: '/src/assets/subject/chineseico.png',
    english: '/src/assets/subject/englishico.png',
    other: '/src/assets/subject/others.png'
  }
  return iconPaths[subject] || iconPaths.other
}

// 导航方法
// 快捷入口跳转方法
const goToHomeworkReview = () => {
  // 【作业回顾】进入 作业回顾页
  router.push('/student/homework-review')
}

const refreshData = () => {
  // 【错题集】进入 错题集页面
  router.push('/student/homework-review/error-collection')
}

const createTask = () => {
  // 【创建任务】点击创建任务进入学生任务创建向导
  router.push('/student/learning-tasks/wizard')
}

const goToPersonalCenter = () => {
  // 【个人中心】点击后进入个人中心
  router.push('/student/profile/personal-center')
}

// 功能卡片跳转方法
const submitHomework = () => {
  // 【作业提交】点击后可调用摄像头提交作业
  showCameraModal.value = true
}

const goToSubmissionHistory = () => {
  // 【提交记录】进入作业提交历史记录页
  router.push('/student/homework-review/submission-history')
}

const goToClassmateList = () => {
  // 【同学档案】点击后进入同学档案列表
  router.push('/student/profile/classmate-list')
}

const goToStudentTasks = () => {
  router.push('/student/learning-tasks')
}

const viewHomework = (homework: any) => {
  console.log('查看作业:', homework)
  // 跳转到作业详情页
  router.push(`/student/learning-tasks/detail/${homework.id}`)
}

const viewAnnouncement = (announcement: any) => {
  console.log('查看公告:', announcement)
}

// 图片数据接收和处理方法
const handlePhotoCapture = async (photoData: PhotoData) => {
  try {
    // 保存图片到本地存储
    await photosStorage.savePhoto(photoData)
    ElMessage.success($t('assets.homework.photoSavedSuccess'))

    // 关闭摄像头模态框
    showCameraModal.value = false

    // 可以在这里添加其他处理逻辑，比如上传到服务器
    console.log('图片已保存:', photoData)
  } catch (error) {
    console.error('保存图片失败:', error)
    ElMessage.error($t('assets.homework.photoSaveError'))
  }
}

// 从本地存储加载图片数据
const loadPhotosFromStorage = async () => {
  try {
    // 添加超时保护
    const timeoutPromise = new Promise((_, reject) => {
      setTimeout(() => reject(new Error('加载图片数据超时')), 5000)
    })

    const photos = await Promise.race([
      photosStorage.getAllPhotos(),
      timeoutPromise
    ])

    console.log('加载的图片数据:', photos)
    // 可以在这里处理加载的图片数据
  } catch (error) {
    console.error('加载图片数据失败:', error)
    // 不抛出错误，避免影响组件渲染
  }
}

// 处理作业提交图片
const handleHomeworkSubmission = async (photoData: PhotoData) => {
  try {
    // 为作业提交添加特殊标记
    const homeworkPhoto = {
      ...photoData,
      category: 'homework',
      submissionTime: new Date().toISOString()
    }

    await photosStorage.savePhoto(homeworkPhoto)
    ElMessage.success($t('assets.dashboard.homeworkSubmittedSuccess'))

    // 可以在这里添加提交到服务器的逻辑
    console.log('作业已提交:', homeworkPhoto)
  } catch (error) {
    console.error('作业提交失败:', error)
    ElMessage.error($t('assets.dashboard.homeworkSubmissionError'))
  }
}

onMounted(async () => {
  try {
    console.log('学生工作台加载完成')
    // 加载本地图片数据
    await loadPhotosFromStorage()
  } catch (error) {
    console.error('学生工作台初始化失败:', error)
    // 不阻止组件渲染，只记录错误
  }
})
</script>

<style scoped>
.student-dashboard {
  height: 100%;
  padding: 20px;
  overflow: hidden;
  background: var(--content-bg-color);
  color: var(--text-color-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
}

.dashboard-container {
  display: flex;
  height: 100%;
  max-width: 100%;
  gap: 20px;
  overflow: hidden;
}

/* 左侧主内容区 */
.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
  min-width: 0; /* 防止flex子项溢出 */
}

/* 标题区域 */
.title-section {
  margin-bottom: 24px;
}

.welcome-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weather-icon {
  font-size: 24px;
}

.greeting {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

/* 功能卡片区 */
.function-cards {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.card-item {
  flex: 1;
  border-radius: 8px;
  padding: 15px 15px 27px;
  cursor: pointer;
  transition: all 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color-secondary);
  box-shadow: var(--card-shadow);
  color: var(--text-color-primary);
  min-height: 200px;
  position: relative;
  overflow: hidden;
  min-width: 0; /* 防止flex子项溢出 */
  max-width: calc(50% - 10px); /* 限制最大宽度 */
}

.card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 卡片渐变背景 - 按照UI设计图 */
.card-item.purple-card {
  background: #f8f4ff;
  border: 1px solid #e8d8ff;
  color: #333;
}

.card-item.green-card {
  background: #f0fff4;
  border: 1px solid #d4edda;
  color: #333;
}

.card-item.blue-card {
  background: #f0f8ff;
  border: 1px solid #cce7ff;
  color: #333;
}

.card-content {
  flex: 1;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-icon {
  text-align: center;
  line-height: 13px;
  width: 21px;
  aspect-ratio: 1;
  flex-shrink: 0;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-content h3 {
  font-size: 16px;
  font-weight: 600;
  color: #000000;
  margin: 0;
}

.card-actions span {
  color: #ffffff;
}

.secondary-btn span {
  color: #ffffff;
}

.card-actions .btn-text {
  color: #ffffff;
}

.card-content p {
  font-size: 14px;
  color: rgb(0, 0, 0);
  line-height: 1.5;
  margin: 0;
}

/* 卡片按钮区域 */
.card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.card-actions span {
  color: #000000;
}

.card-actions .btn-text {
  color: #ffffff;
}

.action-btn {
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.primary-btn {
  background: #2c2c2c;
  color: #fff;
  padding: 6px 12px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 120px;
}

.primary-btn:hover {
  background: #404040;
  transform: translateY(-1px);
}

.btn-text {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.btn-arrow {
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-arrow img {
  width: 16px;
  aspect-ratio: 1;
  object-fit: contain;
  filter: none;
}

.secondary-btn {
  padding: 6px 7px;
  background: #e9ebf3;
  color: #fff;
  /* border: 1px solid rgba(255, 255, 255, 0.3); */
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.secondary-icon {
  width: 16px;
  height: 16px;
}

.secondary-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(0.3);
}

/* 分类列表区 */
.category-section {
  background: #e8f3fe;
  border-radius: 15px;
  padding: 20px;
  border: 1px solid #e4e7ed;
}

/* 分类标签样式 */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 16px;
  color: #909399;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  border-radius: 4px;
}

.category-tab-btn:hover {
  color: #606266;
}

.category-tab-btn.active {
  color: #303133;
  font-weight: 600;
}

.category-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background-color: #3e3e3e;
  border-radius: 1px;
}

.category-tab-btn .count {
  margin-left: 4px;
  font-size: 12px;
  background-color: #d9ecff;
    padding: 5px;
    border-radius: 15px;
}

/* 分割线样式 */
.divider-line {
  height: 1px;
  background-color: #e4e7ed;
  margin: 16px 0;
}

/* 状态标签样式 */
.status-tabs {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.status-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 14px;
  color: #333333;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 0;
  position: relative;
}

.status-tab-btn:hover {
  color: #409EFF;
}

.status-tab-btn.active {
  color: #409EFF;
  background-color: #ffffff;
  border-radius: 16px;
  padding: 8px 16px;
}
  
/* 作业列表 */
.homework-list {
  max-height: 375px;
  overflow-y: auto;
}



.homework-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border: 1px solid #e8e8e8;
  background-color: #ffffff;
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.3s;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  height: 65px; /* PC端固定高度65px */
  min-height: 65px;
}

.homework-item:hover {
  border-color: #409EFF;
  background-color: #f0f9ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.subject-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  flex-shrink: 0;
}

.subject-icon-wrapper.math {
  background: #e8f4fd;
}

.subject-icon-wrapper.chinese {
  background: #e8f4fd;
}

.subject-icon-wrapper.english {
  background: #fff3e0;
}

.subject-icon-wrapper.other {
  background: #fff3e0;
}

.subject-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.homework-content {
  flex: 1;
  min-width: 0;
}

.homework-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 6px 0;
  line-height: 1.4;
}

.homework-desc {
  font-size: 14px;
  color: #909399;
  margin: 0;
  line-height: 1.4;
}

.homework-meta {
  display: flex;
  flex-direction: row;
  gap: 60px;
  min-width: 280px;
  justify-content: flex-start;
  flex-shrink: 0;
}

.homework-time {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  min-width: 110px;
}

.time-label {
  color: #909399;
  font-size: 12px;
  line-height: 1.2;
}

.time-value {
  color: #606266;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
}

.homework-arrow {
  flex-shrink: 0;
  margin-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.6;
  transition: opacity 0.3s;
}

.homework-item:hover .arrow-icon {
  opacity: 1;
}

/* 右侧快捷入口区 */
.sidebar-content {
  width: 300px;
  height: 100%;
  overflow-y: auto;
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 快捷入口区 */
.quick-actions-section {
  background: var(--card-bg-color);
  color: var(--text-color-primary);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border-color-secondary);
  box-shadow: var(--card-shadow);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 16px;
}

.quick-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  gap: 8px;
}

.quick-action-item:hover {
  background-color: #f5f7fa;
  transform: translateY(-1px);
}

.action-icon {
  width: 32px;
  height: 32px;
  background: #f7f8fa;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.action-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.quick-action-item span {
  font-size: 11px;
  color: #606266;
  font-weight: 500;
  line-height: 1.2;
}

/* 轮播图区域 */
.carousel-item-content {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
}

.carousel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 1;
}

.carousel-text {
  position: relative;
  z-index: 2;
  color: white;
  padding: 20px;
  width: 100%;
}

.carousel-text h4 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.carousel-text p {
  font-size: 14px;
  margin: 0;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 自定义轮播图导航条样式 */
.custom-carousel :deep(.el-carousel__indicators) {
  bottom: 6px;
}

.custom-carousel :deep(.el-carousel__indicator) {
  padding: 0px 4px;
}

.custom-carousel :deep(.el-carousel__button) {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.647);
  border: none;
  transition: all 0.3s ease;
}

.custom-carousel :deep(.el-carousel__indicator.is-active .el-carousel__button) {
  width: 16px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.9);
}

.section-header {
  margin-bottom: 16px;
}

.section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin: 0;
}

/* 公告区域 */
.announcement-section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e4e7ed;
}

.announcement-list {
  max-height: 300px;
  overflow-y: auto;
}

.announcement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  cursor: pointer;
}

.announcement-item:last-child {
  padding-bottom: 0;
}

.announcement-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
}

.announcement-tag.activity {
  background: #fef0e6;
  color: #e6a23c;
}

.announcement-tag.info {
  background: #e1f3ff;
  color: #17c0eb;
}

.announcement-tag.warning {
  background: #fef0e6;
  color: #e6a23c;
}

.announcement-tag.notice {
  background: #e1f3ff;
  color: #409EFF;
}

.announcement-content {
  flex: 1;
  overflow: hidden;
}

.announcement-title {
  font-size: 14px;
  color: #606266;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* 滚动条样式 */
.sidebar-content::-webkit-scrollbar,
.homework-list::-webkit-scrollbar,
.announcement-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.homework-list::-webkit-scrollbar-track,
.announcement-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.homework-list::-webkit-scrollbar-thumb,
.announcement-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.homework-list::-webkit-scrollbar-thumb:hover,
.announcement-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .dashboard-container {
    flex-direction: column;
    height: auto;
  }

  .sidebar-content {
    width: 100%;
    padding-left: 0;
    padding-top: 20px;
  }

  .main-content {
    height: auto;
    padding-right: 0;
  }

  .function-cards {
    flex-direction: column;
  }

  .card-item {
    flex: none;
  }
}

/* iPad端样式 */
@media (max-width: 1024px) and (min-width: 769px) {
  .homework-item {
    height: auto;
    min-height: 60px;
    padding: 16px 20px;
  }

  .homework-title {
    font-size: 15px;
  }

  .homework-desc {
    font-size: 13px;
  }

  .time-label,
  .time-value {
    font-size: 11px;
  }

  .homework-meta {
    gap: 40px;
    min-width: 240px;
  }
}

@media (max-width: 768px) {
  .function-cards {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
  }

  .quick-actions-section {
    padding: 16px;
  }

  .action-icon {
    width: 28px;
    height: 28px;
  }

  .action-icon img {
    width: 16px;
    height: 16px;
  }

  .quick-action-item span {
    font-size: 10px;
  }

  .category-tabs,
  .status-tabs {
    justify-content: center;
  }

  .homework-item {
    height: auto;
    min-height: 50px;
    padding: 12px 16px;
  }

  .homework-title {
    font-size: 14px;
  }

  .homework-desc {
    font-size: 12px;
  }

  .subject-icon-wrapper {
    width: 36px;
    height: 36px;
  }

  .subject-icon {
    width: 24px;
    height: 24px;
  }

  .homework-meta {
    display: none;
  }
}

@media (max-width: 480px) {
  .dashboard-container {
    gap: 16px;
  }

  .card-item {
    flex-direction: column;
    text-align: center;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
  }

  .quick-actions-section {
    padding: 12px;
  }

  .quick-action-item {
    flex-direction: column;
    padding: 8px;
    gap: 6px;
  }

  .action-icon {
    width: 24px;
    height: 24px;
  }

  .action-icon img {
    width: 14px;
    height: 14px;
  }

  .quick-action-item span {
    font-size: 9px;
  }
}
</style>